*********************************************************************************
/*   Single-diff event study showing changes in taxes paid post-audit	*/
*********************************************************************************
* Set directories 
adopath + "${oi_home}/Research files/ado"

* File paths
local datapath "${mvpf_audits}/data/cleaned" 
local datafolder "${mvpf_audits}/data/outside" 
local graphpath "${graphpath}" 

* Version of fig to produce 
global version  ${version} // paper or slides

* Other formatting
if "${version}" == "slides" {
	global title "title(" ", size(vhuge))"
	global img wmf
	graph set window fontface "Arial"
	global title "title(" ", size(vhuge))"
	global axis_size "" //xsize(6.5) ysize(4)" // makes figure wider
}

else if "${version}" == "paper" {
	global title "title("")"
	global img pdf
	graph set window fontface "LMRoman10-Regular"
	global title " "
	global axis_size " " // makes figure wider
}

* Import data
use "${mvpf_audits}/data/figures_rep/figure_6.txt", clear

* keep coefficient of interest 
g row = _n

keep if inrange(row, 29,56)

split v1, p(" # ") g(nrp)
carryforward nrp2, gen(nrp)
keep if nrp =="nrp=1"
drop nrp1 nrp2 row

destring totaltaxminuseitcwins99, replace
rename totaltaxminuseitcwins99 coeff
rename v5 se
g row = _n


drop if missing(v1)
drop nrp row 
g row = _n
g event = row-14
*drop if missing(coeff)

* Generate standard errore and 95% CI
g coeff_h = (coeff + 1.96*se)
g coeff_l = (coeff - 1.96*se)
*
drop if event <-13
*
if "${version}"=="paper"{
	twoway  (scatter coeff event, mc(gs4) ms(O)) ///
			(rcap coeff_h coeff_l event, lc(gs4)) ///
			(line coeff event, lc(gs4)) ///
			, ///
			xline(0.5, lw(vthin) lc(gs11)) ///
			yline(0, lw(vthin) lc(gs11)) ///
			xtitle("Year relative to tax year of audited return") ///
			ytitle("Taxes Paid") ///
			xlabel(-12(2)14 , nogrid)  ///
			ylab(, nogrid format(%5.0fc))  ///
			legend(off) ///
			${title} ${axis_size}	
graph export "`graphpath'/event_study_taxes_paid.wmf", as(wmf) replace
}

if "${version}"=="slides"{
	twoway  (scatter coeff event, mc(gs4) ms(O)) ///
			(rcap coeff_h coeff_l event, lc(gs4)) ///
			(line coeff event, lc(gs4)) ///
			, ///
			xline(0.5, lw(vthin) lc(gs11)) ///
			yline(0, lw(vthin) lc(gs11)) ///
			xtitle("Year relative to tax year of audited return") ///
			ytitle("Taxes Paid") ///
			xlabel(-14(2)14 , nogrid)  ///
			ylab(-400 "-400" -200 "200" 0 "0" 200 "200" 400 "400" 600 "600" ///
				  800 "0,800", nogrid format(%5.0fc)) yscale(r(-400 850))  ///
			legend(ring(0) pos(11) row(2) symxsize(*0.3) order(5 3) ///
			lab(5 "2006-2009") lab(3 "2010-2014")) ///
			${title} ${axis_size}	
graph export "`graphpath'/event_study_taxes_paid.wmf", as(wmf) replace
}